<template>
  <div class="app">
    <el-container class="page-user">
      <el-aside width="200px" style="height: 100%;">
        <el-main class="nopadding">
          <el-menu class="menu" :default-active="page">
            <el-menu-item-group v-for="group in menu" :key="group.groupName" :title="group.groupName">
              <el-menu-item v-for="item in group.list" :key="item.component" :index="item.component" @click="openPage">
                <el-icon v-if="item.icon">
                  <component :is="item.icon" />
                </el-icon>
                <template #title>
                  <span>{{ item.title }}</span>
                </template>
              </el-menu-item>
            </el-menu-item-group>
          </el-menu>
        </el-main>
      </el-aside>
      <el-main class="page-content has-sidebar">
        <Suspense>
          <template #default>
            <component :is="page" />
          </template>
          <template #fallback>
            <el-skeleton :rows="1" />
          </template>
        </Suspense>
      </el-main>
    </el-container>
  </div>
</template>

<script>
import { defineAsyncComponent } from 'vue'
export default {
  name: "dashboard",
  components: {
    report: defineAsyncComponent(() => import('../message/report.vue')),
    warn: defineAsyncComponent(() => import('../message/warn.vue')),
    manage: defineAsyncComponent(() => import('../message/manage.vue')),
    ticket: defineAsyncComponent(() => import('../message/ticket.vue')),
  },
  data() {
    return {
      menu: [
        {
          groupName: "质量报告",
          list: [
            {
              icon: "el-icon-postcard",
              title: "问题预警",
              component: "warn"
            }
          ]
        },
        {
          groupName: "质量规则",
          list: [
            {
              icon: "el-icon-Tools",
              title: "规则管理",
              component: "manage"
            },
            {
              icon: "el-icon-coin",
              title: "规则模板",
              component: "report"
            },
            {
              icon: "el-icon-Tickets",
              title: "规则标签",
              component: "ticket"
            }
          ]
        },
      ],
      page: "report"
    }
  },
  created() {
  },
  mounted() {

  },
  methods: {
    openPage(item) {
      this.page = item.index
    }
  }
}
</script>

<style></style>